/*****************************************************************************************************************
 * robot_object.h
 * 描述:定义一个需要序列化传递的类.
 * 作者:xhome
 * 时间:2020/5/21
 ****************************************************************************************************************/

#include "robot_object.h"

void RobotObject::read(InputMemoryBitStream & in_input_stream)
{
    int lon, lat, alt;

    in_input_stream.read(id_);
    in_input_stream.read(group_id_);
    in_input_stream.read(state_);

    in_input_stream.read(pos_count);
    for(int i = 0; i < pos_count; i++)
    {

        in_input_stream.read(lon);
        in_input_stream.read(lat);
        in_input_stream.read(alt);

        pos_list_.push_back(pos(lon, lat, alt));
    }

}

void RobotObject::write(OutputMemoryBitStream & in_output_stream)
{
    in_output_stream.write(id_);
    in_output_stream.write(group_id_);
    in_output_stream.write(state_);
    in_output_stream.write((uint32_t)pos_list_.size()); //注意需要类型强制转换.

    for(int i =0; i < pos_list_.size(); i++)
    {
        in_output_stream.write(pos_list_[i].lon);
        in_output_stream.write(pos_list_[i].lat);
        in_output_stream.write(pos_list_[i].alt);
    }

}